package cn.njupt.cmpSort;


public class BubbleSort2<E extends Comparable<E>> extends Sort<E>{

    @Override
    public void sort() {
        boolean sort=true;
        for (int end = array.length-1; end >=1 ; end--) {
            sort=true;
            for(int begin=1;begin<=end;begin++){
                if(cmp(begin,begin-1)<0){
                    swap(begin,begin-1);
                    sort=false;
                }
            }
            if(sort)break;
        }
    }
}
